extends Node2D
class_name SimpleGameManager

# 简化的游戏管理器，不依赖外部场景文件
var game_state = "playing"
var score = 0
var lives = 3
var current_level = 1

# UI引用
@onready var score_label = $UI/GameUI/ScoreLabel
@onready var lives_label = $UI/GameUI/LivesLabel
@onready var level_label = $UI/GameUI/LevelLabel
@onready var game_over_screen = $UI/GameUI/GameOverScreen
@onready var restart_button = $UI/GameUI/GameOverScreen/GameOverPanel/RestartButton

func _ready():
	# 连接按钮信号
	if restart_button:
		restart_button.pressed.connect(_on_restart_button_pressed)
	
	# 开始游戏
	start_game()

func start_game():
	# 重置游戏状态
	game_state = "playing"
	score = 0
	lives = 3
	current_level = 1
	
	# 更新UI
	update_ui()
	
	# 隐藏游戏结束界面
	if game_over_screen:
		game_over_screen.visible = false
	
	print("游戏开始！")

func update_ui():
	if score_label:
		score_label.text = "分数: " + str(score)
	if lives_label:
		lives_label.text = "生命: " + str(lives)
	if level_label:
		level_label.text = "关卡: " + str(current_level)

func _on_restart_button_pressed():
	print("重新开始游戏")
	start_game()

func _input(event):
	# 简单的输入处理
	if event is InputEventKey and event.pressed:
		match event.keycode:
			KEY_ESCAPE:
				get_tree().quit()
			KEY_R:
				start_game()
			KEY_SPACE:
				print("射击！")
				score += 10
				update_ui()
